package apps.buscoplan.persist;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import android.app.Activity;
import android.content.Context;

public class Settings {
	public final static String FILE_PATH = ".settings";
	public final static int MAX_ACCOUNT_LEN = 128;
	public Settings () {
		
	}
	
	public static void saveAccount (String account, Activity activity) throws IOException
	{
		FileOutputStream fos = activity.openFileOutput(FILE_PATH, Context.MODE_PRIVATE);
		fos.write(account.getBytes());
		fos.close();
	}
	
	public static String getAccount (Activity activity) throws IOException
	{
		FileInputStream fis = activity.openFileInput(FILE_PATH);
		byte [] buffer = new byte [MAX_ACCOUNT_LEN];
		fis.read(buffer);
		fis.close();
		
		String accountReaded = new String(buffer);
		return accountReaded;
	}
}
